<template>
  <div class="cmt-container">
    <h2>发表评论</h2>
    <hr />
    <textarea placeholder="请输入套BB的内容(最多吐槽120字)" maxlength="120"></textarea>
    <!-- 发表评论 -->
    <mt-button type="primary" size="large">发表评论</mt-button>
    <!-- 评论内容 -->
    <div class="cmt-list">
      <div class="ctm-item">
        <div class="cmt-title">第一楼&nbsp;&nbsp;用户：&nbsp;&nbsp;发布时间：</div>
        <div class="cmt-body">顺丰到付到付</div>
      </div>
    </div>
    <!-- 加载更多 -->
    <mt-button type="danger" size="large" plain>加载更多</mt-button>
  </div>
</template>

<script>
import axios from 'axios'
import { Toast } from 'mint-ui'
export default {
  props: ['id'],
  data() {
    return {
      pageindex: 1, //默认页面
      comments: [] //评论信息
    }
  },
  created() {
    this.getComments()
  },
  methods: {
    getComments() {
      axios.get('api/getcomments/' + this.id + '?pageindex=' + this.pageIndex).then(res => {
        console.log(res)
        if (res.data.status === 0) {
          this.comments = res.data.message
        } else {
          Toast('获取评论信息失败...')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.cmt-container {
  h2 {
    font-size: 18px;
  }
  textarea {
    font-size: 14px;
    height: 85px;
    margin: 0;
  }
  .cmt-list {
    margin: 5px 0;
    .ctm-item {
      font-size: 13px;
      .cmt-title {
        line-height: 30px;
        background-color: #ccc;
      }
      .cmt-body {
        line-height: 35px;
        text-indent: 2em; //首行缩进
      }
    }
  }
}
</style>
